package
{
	import flash.display.Sprite;
	
	import org.ioflow.IOflow;
	import org.ioflow.events.ConnectionFailEvent;
	import org.ioflow.events.ConnectionSuccessEvent;
	import org.ioflow.events.MessageEvent;
	

	
	public class IoflowTest extends Sprite
	{
		public function IoflowTest()
		{
//			const soc:WebSocket = new WebSocket(function(message:String):void
//			{
//				trace(message);
//			});
//			
//			soc.addEventListener(WebSocketEvent.CONNECT, function(event:WebSocketEvent):void
//			{
//				soc.send("ddddddddddddddd");
//			});
//			soc.connect("ws://localhost:8080/io/__webSocket__/");
			
			const soc:IOflow = new IOflow();
			soc.addEventListener(ConnectionSuccessEvent.TYPE, function(ev:ConnectionSuccessEvent):void
			{
				trace("connection success");
				soc.send({mess:"dddd"});
			});
			soc.addEventListener(MessageEvent.TYPE, function(ev:MessageEvent):void
			{
				trace(JSON.stringify(ev.message));
			});
			soc.addEventListener(ConnectionFailEvent.TYPE, function(ev:ConnectionFailEvent):void
			{
				trace("FAILED", ev.reason);
			});
			soc.connect("ws://localhost:8080/io");
		}
	}
}